package archimede;

import java.awt.Font;
import java.awt.Graphics;
import java.util.Scanner;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import net.miginfocom.swing.MigLayout;

public class Strumenti extends JPanel {

	private JRadioButton igrometro = new JRadioButton("Analisi ponderale DARR");
	private JRadioButton infrarossi = new JRadioButton("Analisi termografica");
	private JRadioButton regUmidita = new JRadioButton("Analisi igrometrica'");
	private JRadioButton datalogger = new JRadioButton(
			"Analisi dei Sali con il Salt Detector");
	private JRadioButton analUmidita = new JRadioButton(
			"Analisi del potenziale elettrico tra i materiali");
	private JRadioButton clima = new JRadioButton("Monitoraggio climatico");
	private JRadioButton critico = new JRadioButton("Rilievo critico");

	protected void paintComponent(Graphics g) {
		setOpaque(false);
		g.drawImage(
				(new ImageIcon(ClassLoader.getSystemResource("sfondo.jpg")))
						.getImage(), 0, 0, null);
		super.paintComponent(g);
	}

	public Strumenti() {
		super();
		setLayout(new MigLayout("", "", "25[]10[]10[]10[]10[]10[]"));

		JLabel descrittiva = new JLabel("Strumentazione usata");
		descrittiva.setFont(new Font("Arial", Font.BOLD, 20));

		igrometro.setFont(new Font("Arial", Font.PLAIN, 18));
		infrarossi.setFont(new Font("Arial", Font.PLAIN, 18));
		regUmidita.setFont(new Font("Arial", Font.PLAIN, 18));
		datalogger.setFont(new Font("Arial", Font.PLAIN, 18));
		analUmidita.setFont(new Font("Arial", Font.PLAIN, 18));
		clima.setFont(new Font("Arial", Font.PLAIN, 18));
		critico.setFont(new Font("Arial", Font.PLAIN, 18));

		igrometro.setOpaque(false);
		infrarossi.setOpaque(false);
		regUmidita.setOpaque(false);
		datalogger.setOpaque(false);
		analUmidita.setOpaque(false);
		clima.setOpaque(false);
		critico.setOpaque(false);
		//
		add(descrittiva, "wrap , gapleft 15");
		add(igrometro, "wrap, gapleft 15");
		add(infrarossi, "wrap, gapleft 15");
		add(regUmidita, "wrap, gapleft 15");
		add(datalogger, "wrap, gapleft 15");
		add(analUmidita, "wrap, gapleft 15");
		add(clima, "wrap, gapleft 15");
		add(critico, "wrap, gapleft 15");

	}

	public String print() {
		String print = "\n#" + igrometro.isSelected();
		print = print + "\n#" + infrarossi.isSelected();
		print = print + "\n#" + regUmidita.isSelected();
		print = print + "\n#" + datalogger.isSelected();
		print = print + "\n#" + analUmidita.isSelected();
		print = print + "\n#" + clima.isSelected();
		print = print + "\n#" + critico.isSelected();
		print = print + "\n@@Strumenti";

		return print;
	}

	public void setElement(String data) {
		Scanner c = new Scanner(data);
		// System.out.println(data);
		c.nextLine();
		if (c.nextLine().substring(1).equals("true"))
			igrometro.setSelected(true);
		else
			igrometro.setSelected(false);

		if (c.nextLine().substring(1).equals("true"))
			infrarossi.setSelected(true);
		else
			infrarossi.setSelected(false);

		if (c.nextLine().substring(1).equals("true"))
			regUmidita.setSelected(true);
		else
			regUmidita.setSelected(false);

		if (c.nextLine().substring(1).equals("true"))
			datalogger.setSelected(true);
		else
			datalogger.setSelected(false);

		if (c.nextLine().substring(1).equals("true"))
			analUmidita.setSelected(true);
		else
			analUmidita.setSelected(false);

		if (c.nextLine().substring(1).equals("true"))
			clima.setSelected(true);
		else
			clima.setSelected(false);

		if (c.nextLine().substring(1).equals("true"))
			critico.setSelected(true);
		else
			critico.setSelected(false);
	}

	

}
